package com.googlecode.gwtbb.client.shared.entity.forum;

import com.googlecode.gwtbb.client.shared.entity.properties.HasCreateDate;
import com.googlecode.gwtbb.client.shared.entity.properties.HasId;
import com.googlecode.gwtbb.client.shared.entity.user.User;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Apr 17, 2008
 */
public class Post extends PostBase implements HasCreateDate, HasId {
	private Date createDate;
	private Info info;

	public Post() {
	}

	public Post(Long postId, Long threadId, Long forumId, Long userId, String subject, String body, Date snapDate, Date createDate) {
		super(postId, threadId, forumId, userId, subject, body, snapDate);
		this.createDate = createDate;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Info getInfo() {
		return info;
	}

	public void setInfo(Info info) {
		this.info = info;
	}

	public Long getId() {
		return postId;
	}

	public boolean isThread() {
		return getId().equals(getThreadId());
	}

	public void setId(Long id) {
		this.postId = id;
	}

	/**
	 * @author Abraham Grief
	 * @version $Id$
	 * @since Jul 6, 2008
	 */
	public static class Info implements HasId, Serializable {
		private Long postId;
		private int numPostsInThread;
		private Long lastPostInThreadId;
		private Post thread;
		private User user;
		private Post lastPostInThread;

		public Post getLastPostInThread() {
			return lastPostInThread;
		}

		public void setLastPostInThread(Post lastPostInThread) {
			this.lastPostInThread = lastPostInThread;
		}

		public Long getLastPostInThreadId() {
			return lastPostInThreadId;
		}

		public void setLastPostInThreadId(Long lastPostInThreadId) {
			this.lastPostInThreadId = lastPostInThreadId;
		}

		public int getNumPostsInThread() {
			return numPostsInThread;
		}

		public void setNumPostsInThread(int numPostsInThread) {
			this.numPostsInThread = numPostsInThread;
		}

		public Long getPostId() {
			return postId;
		}

		public void setPostId(Long postId) {
			this.postId = postId;
		}

		public Post getThread() {
			return thread;
		}

		public void setThread(Post thread) {
			this.thread = thread;
		}

		public User getUser() {
			return user;
		}

		public void setUser(User user) {
			this.user = user;
		}

		public Long getId() {
			return postId;
		}

		public void setId(Long id) {
			this.postId = id;
		}
	}
}
